<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;

/**
* @var yii\web\View $this
* @var yii\data\ActiveDataProvider $dataProvider
    * @var yiike\company\model\TtycTokerComboOrderSearch $searchModel
*/

$this->title = Yii::t('models', '推客订单');
$this->params['breadcrumbs'][] = $this->title;

if (isset($actionColumnTemplates)) {
$actionColumnTemplate = implode(' ', $actionColumnTemplates);
    $actionColumnTemplateString = $actionColumnTemplate;
} else {
Yii::$app->view->params['pageButtons'] = Html::a('<span class="glyphicon glyphicon-plus"></span> ' . 'New', ['create'], ['class' => 'btn btn-success']);
    $actionColumnTemplateString = "{view} {update} {delete}";
}
$actionColumnTemplateString = '<div class="action-buttons">'.$actionColumnTemplateString.'</div>';
?>
<div class="box box-info giiant-crud ttyc-toker-combo-order-index">
    <div class="box-header with-border">
        <div class="box-title">
            <?= Yii::t('models', '推客订单') ?>
        </div>
    </div>
    <div class="box-body">
    <?php
//             echo $this->render('_search', ['model' =>$searchModel]);
        ?>

    
    <?php \yii\widgets\Pjax::begin(['id'=>'pjax-main', 'enableReplaceState'=> false, 'linkSelector'=>'#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success'=>'function(){alert("yo")}']]) ?>


    <div class="clearfix crud-navigation">
        <div class="pull-left">
            <?= Html::a('导出', ['export'], ['class' => 'btn btn-success']) ?>
        </div>

        <div class="pull-right">

            <div class="pull-right">
                <?= Html::a('<span class="glyphicon glyphicon-list"></span> '
                    . '推客列表', ['ttyc-toker/index','type'=>'toker'], ['class'=>'btn btn-default']) ?>
            </div>

        </div>
    </div>

    <hr />

    <div class="table-responsive">
        <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'pager' => [
        'class' => yii\widgets\LinkPager::className(),
        'firstPageLabel' => 'First',
        'lastPageLabel' => 'Last',
        ],
                    'filterModel' => $searchModel,
                'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'],
        'headerRowOptions' => ['class'=>'x'],
        'columns' => [
                [
            'class' => 'yii\grid\ActionColumn',
            'template' => $actionColumnTemplateString,
            'buttons' => [
                'view' => function ($url, $model, $key) {
                    $options = [
                        'title' => Yii::t('cruds', 'View'),
                        'aria-label' => Yii::t('cruds', 'View'),
                        'data-pjax' => '0',
                    ];
                    return '';
                },
                'delete'=>function ($url, $model, $key) {
                    $options = [
                        'title' => Yii::t('cruds', 'View'),
                        'aria-label' => Yii::t('cruds', 'View'),
                        'data-pjax' => '0',
                    ];
                    return '';
                },
                'update'=>function ($url, $model, $key) {
                    $options = [
                        'title' => Yii::t('cruds', '发货'),
                        'aria-label' => Yii::t('cruds', '发货'),
                        'data-pjax' => '0',
                    ];
                    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, $options);
                },
            ],
            'urlCreator' => function($action, $model, $key, $index) {
                // using the column name as key, not mapping to 'id' like the standard generator
                $params = is_array($key) ? $key : [$model->primaryKey()[0] => (string) $key];
                $params[0] = \Yii::$app->controller->id ? \Yii::$app->controller->id . '/' . $action : $action;
                return Url::toRoute($params);
            },
            'contentOptions' => ['nowrap'=>'nowrap']
        ],
			'id',
			//'toker_id',
			//'combo_id',
			//'trade_id',
            'name',
			'pay_id',
			'title',
			'sub_title',
            'mobile',
			'price',
            [
                'label'=>'状态',
                // 'format'=>'raw',
                'attribute'=>'status',
                'content'=>function($model){
                    if($model->status==0){
                        return Html::label('待付款','',['class'=>'label label-default']);
                    }else if($model->status==1){
                        return Html::label('待发货','',['class'=>'label label-warning']);
                    }
                    else if($model->status==2){
                        return Html::label('已发货','',['class'=>'label label-primary']);
                    }
                    else if($model->status==3){
                        return Html::label('已完成','',['class'=>'label label-success']);
                    }
                    else if($model->status==4){
                        return Html::label('已取消','',['class'=>'label label-info']);
                    }
                },
                'filter' => [0=>'待付款',1=>'待发货',2=>'已发货',3=>'已完成',4=>'已取消'],//重点在这里，传入一个数组，会下拉框显示
            ],
			/*'credit',*/
			/*'task_money',*/
			/*'task_tyc',*/
			/*'day_limit',*/
			/*'parent1_commision',*/
			/*'parent2_commision',*/
			/*'community_commision',*/
			/*'company_commision',*/
			/*'pid',*/
			/*'ppid',*/
			/*'community_id',*/
			/*'company_id',*/
			/*'is_pay',*/
			/*'pay_at',*/
			/*'status',*/
			/*'location_p',*/
			/*'location_c',*/
			/*'location_a',*/
			/*'express_company',*/
			/*'express_code',*/
			/*'address',*/
        ],
        ]); ?>
    </div>
        <?php \yii\widgets\Pjax::end() ?>
    </div>
</div>




